package work20250104;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author zdl
 * @date 2025/1/4
 */
public class Demo7 {
    public static void main(String[] args) {
        /**
         * 数组题目：键盘输入十名学生的成绩，将成绩降序排列，并打印（降序，即由大到小）（使用冒泡或者选择排序算法实现）。(12分)
         */
        Scanner sc = new Scanner(System.in);
        int count = 0;
        double[] arr = new double[10];
        while (count < 10) {
            System.out.println("请输入第:" + (count + 1) + "名学生成绩:");
            double v = sc.nextDouble();
            arr[count++] = v;
        }
        System.out.println("原始数据:" + Arrays.toString(arr));
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = 0; j < arr.length - 1 - i; j++) {
                if (arr[j] < arr[j + 1]) {
                    double temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
        System.out.println("排序后数据:" + Arrays.toString(arr));
    }
}
